package com.tts.superstar.fragment;


import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tts.superstar.R;
import com.tts.superstar.SetupActivity;

import static android.content.Context.MODE_PRIVATE;

/**
 * Created by Administrator on 2019/4/11.
 */

public class MyFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.my_layout, container, false);

        LinearLayout linearLayout = (LinearLayout)view.findViewById(R.id.ll_setup);
        linearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), SetupActivity.class);
                startActivity(intent);

            }
        });

        TextView textView = view.findViewById(R.id.text_userName);
        SharedPreferences preferences =  getActivity().getSharedPreferences("account",MODE_PRIVATE);
        String userName = preferences.getString("User","请登录");
        textView.setText(userName);
        return view;
    }
}
